Skip to content

fix(commit): refuse commit checks and commits while a commit confirmed is pending (#632) - #635

Merged
fastrevmd-lab merged 2 commits into
mainfrom
fix/pending-confirm-guard
Nov 11, 2026
Merged

fastrevmd-lab merged 2 commits into
mainfrom
fix/pending-confirm-guard

Conversation

@fastrevmd-lab

Copy link
Copy Markdown
Member

Summary

On Junos, a commit check or a commit made while a commit confirmed is pending silently confirms it. No new entry is written and no rollback happens (verified on a lab vSRX, evidence in #632). Five tools run a commit check or commit with no check for that, so a "validate only" call could cancel another session's safety rollback:

  • commit_check_config
  • load_and_commit_config
  • render_and_apply_j2_template
  • rollback_config
  • apply_junos_change_set

They now refuse with commit_confirmed_active while a commit confirmed is pending. This is part 2 of #632. Part 3 (settled entries read as pending) is #634.

Changes

  • Candidate pipeline (candidate_transaction.rs):
    • primary_operation reads show system commit under the candidate lock, before loading anything. If commit_confirm_pending (fix(upgrade_junos): detect a pending commit confirmed from rollback pending (#632) #633) says entry 0 is pending, it refuses, and the existing cleanup reverts and unlocks.
    • Every mode except DryRun is guarded. DryRun never commit-checks.
    • To read the log, the production CandidateBackend impl moves from ConfigManager (which has no CLI) to rustez::Device. Each method takes a ConfigManager per call; it is a stateless view, and the private-database flag lives on Device.
  • Change-set path (junos_transaction.rs stage()):
    • The same check runs right after the lock and the Mist plane check, through revert_and_release.
    • The lock is held through validate and commit, so this one check covers them.
    • The confirm path (confirm_commit, confirm_junos_change_set) is not guarded, because confirming a pending commit is its job.
  • Typed refusal through the coordinator:
    • The coordinator stringifies stage errors, and only PlaneManagedConfig was rebuilt.
    • The plane_refusal side channel becomes stage_refusal and carries both refusals, so the change-set path audits error_kind=commit_confirmed_active like the direct tools.
  • Error rename: UpgradeCommitConfirmedActive becomes CommitConfirmedActive. Its code (commit_confirmed_active) and message are unchanged.
  • Docs: docs/REFERENCE.md no longer tells callers that another load_and_commit_config or rollback_config confirms a window. It says they refuse, and names confirm_junos_change_set and confirm_commit. There's also a new CHANGELOG bullet.

Verification

cargo fmt -p rust-junosmcp-core -p rust-junosmcp -p rust-junosmcp-auth -p rust-junosmcp-srx-core -- --check   # exit 0
cargo clippy -p rust-junosmcp-core -p rust-junosmcp -p rust-junosmcp-auth -p rust-junosmcp-srx-core --all-targets -- -D warnings   # exit 0
cargo test --workspace                                       # 1673 passed, 0 failed
cargo test -p rust-junosmcp --no-default-features --locked   # 353 passed, 0 failed

The new tests:

  • Unit: each committing mode refuses on the captured pending log without loading, checking or committing, and still unlocks. DryRun is not blocked, and a settled log lets a commit check through.
  • E2E (fake NETCONF device): commit_check_config and apply_junos_change_set refuse. No validate or commit RPC reaches the device, and the audit error_kind is commit_confirmed_active for both.

I broke the code four ways, one at a time, and each time only the intended tests failed:

Sabotage Tests that failed
Candidate guard never refuses pending_commit_confirmed_refuses_every_committing_mode, commit_check_is_refused_while_a_commit_confirmed_is_pending
Change-set stage() guard never refuses changeset_apply_is_refused_while_a_commit_confirmed_is_pending
Dry runs guarded too pending_commit_confirmed_does_not_block_dry_run
Refusal not recorded for the coordinator changeset_apply_is_refused_while_a_commit_confirmed_is_pending (audit kind)

The Codex gate ran two rounds:

  • Round 1 (19ac927): one P2. The change-set refusal lost its type at the coordinator and was audited as invalid_input. It's fixed in 748542d, and the sabotage table's last row covers it.
  • Round 2 (748542d): one P2, which I rejected. Codex asked to keep the removed take_plane_refusal as an alias for SemVer, and the same argument would apply to the error-variant rename. But rust-junosmcp-core is not published: crates.io returns 404 and no workflow publishes it. Its only dependents are this workspace's rust-junosmcp and rust-junosmcp-srx-core, both updated here. The compatibility rule in AGENTS.md covers MCP schemas, scopes and audit behaviour, all of which are unchanged.

Checklist

  • cargo fmt ... -- --check passes
  • cargo clippy ... -D warnings passes
  • cargo test --workspace and the --no-default-features build pass
  • Tests added or updated, and they fail against the old code (see the table)
  • cargo audit / cargo deny check bans sources: not run, no dependency changes
  • Device-facing path: yes, config load and commit. The change only adds a read (show system commit) and a refusal before anything is loaded. Validation, the exact diff and confirmed commit with rollback are untouched. The refusal goes through the existing revert-and-unlock cleanup, and a failed read fails closed.
  • Fixtures are synthetic: no, on purpose. The e2e pending log is the captured PENDING_LOG from commit_attribution.rs (lab vSRX, 24.4R1.9), closed with </output> for the fake. It contains no hostname, serial or credential.
  • No new telemetry, analytics or outbound network call
  • Deterministic code decides

Anything you're unsure about

  • Behaviour change:
  • Fail closed on read errors: if show system commit cannot be read, the candidate tools and change-set apply now fail instead of proceeding. A login class without view permission would break them.
  • Other sessions:
    • The check runs under our candidate lock, so other sessions can't open a commit confirmed between the check and our commit. I have not re-verified that on hardware for configure private sessions.
    • Not covered: SRX signature-package workflows, which make their own commits and already audit-warn on a pending confirm.
  • Not exercised on hardware: this branch was not run against a live device. The detector and its fixtures are from hardware (fix(upgrade_junos): detect a pending commit confirmed from rollback pending (#632) #633). The guard placement is covered by the fake-device e2e tests.

🤖 Generated with Claude Code

fastrevmd-lab and others added 2 commits November 11, 2026 00:28
…d is pending (#632)

On Junos a commit check or commit made while a commit confirmed is pending
confirms it silently: no new entry, no rollback. commit_check_config,
load_and_commit_config, render_and_apply_j2_template, rollback_config and
apply_junos_change_set now read `show system commit` under the candidate lock,
before loading anything, and refuse with commit_confirmed_active. Dry runs,
which never commit-check, are not guarded, and neither is the confirm path.

UpgradeCommitConfirmedActive becomes CommitConfirmedActive; its code and
message are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…aging

The coordinator stringifies stage errors and apply_change_set_with_cancel
rebuilt only PlaneManagedConfig, so the change-set path's new
CommitConfirmedActive surfaced as Validation and was audited as
invalid_input. The plane_refusal side channel becomes stage_refusal and
carries both refusals; the e2e tests now pin the audit error_kind for
commit_check_config and apply_junos_change_set. (#632)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fastrevmd-lab
fastrevmd-lab force-pushed the fix/pending-confirm-guard branch from 748542d to 7867fcb Compare November 11, 2026 05:33
@fastrevmd-lab
fastrevmd-lab merged commit bf97118 into main Nov 11, 2026
12 checks passed
@fastrevmd-lab
fastrevmd-lab deleted the fix/pending-confirm-guard branch November 11, 2026 05:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant